// pages/selectGender/selectGender.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    identityType: '',
    identities: [
      { label: '老师', value: 'TEACHER' },
      { label: '师范生', value: 'STUDENT' }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.key) {
      this.setData({
        identityType: options.key
      })
    }
  },

  setIdentityType({ currentTarget }) {
    this.setData({ identityType: currentTarget.dataset.val })
  },

  done(e) {
    const pages = getCurrentPages();
    let prevPage = pages[pages.length - 2];
    prevPage.setData({
      'form.identityType': this.data.identityType,
      identityType: { TEACHER: '老师', STUDENT: '师范生' }[this.data.identityType]
    })
    wx.navigateBack({
      delta: 1,
    })
  }

})
